
﻿var global_link_name = '';
﻿var link_id = 0;
$(document).ready(function(){

    
    $('.ui-close').click($.unblockUI); 
  	 /*
    $("div[id^=link]").click(function(){
	 
		if($(this).attr("class") == "item active"){
		//if($(this).css("opacity") == 1){	 
			link_id = ($(this).attr("id")).replace("link_","");
			for(i = 0;i<28;i++)
			{
				document.getElementById(i).style.display = "none";
			}
			document.getElementById(link_id).style.display = "block";
			var link_name = $(this).attr("name");
			 
			SetLtbCssSelected(link_name); 
			 
			$.blockUI({   
					message: $('#lightbox'),   
					overlayCSS: {        
						backgroundColor: '#8E8E8E',        
						opacity: 0.5,
						cursor:'default'
					},
					css: {   
						width: '480px',
						height: '533px',
						left:	'180px', 
						display: 'block', 
						border: 'solid 2px #3a567e',
					}
			});
			$('.blockOverlay').attr('title','Click to unblock').click($.unblockUI);    
		}
    });
	*/
	$("#arrow-left").click(
	
		function(){
			document.getElementById(link_id).style.display = "none";
			if(link_id != 0){
				link_id = link_id - 1;
			}else
			{
				link_id = 27;
			}
				document.getElementById(link_id).style.display = "block";
				var link_newid = "link_"+link_id;
				$("#img-lightbox").attr("src","images/"+$("#"+link_newid).attr("name")+".jpg");
				$("#title-lightbox").attr("src","images/title-"+$("#"+link_newid).attr("name")+".png");
				global_link_name = $("#"+link_newid).attr("name");
				//changeImgSize($("#"+link_newid).attr("name"));
				
		
		});
		
	$("#arrow-right").click(
	function(){		
		document.getElementById(link_id).style.display = "none";
		if(link_id != 27){
			link_id++;			
		}else
		{
			link_id = 0;
		}	
			document.getElementById(link_id).style.display = "block";
			var link_newid = "link_"+link_id;
			$("#img-lightbox").attr("src","images/"+$("#"+link_newid).attr("name")+".jpg");
			$("#title-lightbox").attr("src","images/title-"+$("#"+link_newid).attr("name")+".png");
			global_link_name = $("#"+link_newid).attr("name");
			//changeImgSize($("#"+link_newid).attr("name"));
	
	});
	
  
});
function clickimage(num,name){
	 
			link_id=num;
			for(i = 0;i<28;i++)
			{
				document.getElementById(i).style.display = "none";
			}
			document.getElementById(num).style.display = "block";
			 
			SetLtbCssSelected(name); 
			var bodywidth=document.body.clientWidth/2 -227; 
			$.blockUI({   
					message: $('#lightbox'),   
					overlayCSS: {        
						backgroundColor: '#8E8E8E',        
						opacity: 0.5,
						cursor:'default'
					},
					css: {   
						width: '480px',
						height: '533px',
						left:	bodywidth, 
						display: 'block', 
						border: 'solid 2px #3a567e',
					}
			});
			$('.blockOverlay').attr('title','Click to unblock').click($.unblockUI);    
		
    }

  
function SetLtbCssSelected(link_name)
{//設定lightbox選中大小圖的css、圖檔來源
	//$("div[id^=link]").attr("src","images/StacyKeibler.jpg");  //將大圖替換成目前選中的圖
	$("#img-lightbox").attr("src","images/"+link_name+".jpg");
	global_link_name = link_name;
	//$("#title-lightbox").attr("src","images/title-"+link_name+".png");
	
	//alert($("#img-lightbox").attr("src"));
	//changeImgSize(link_name);
}

function changeImgSize(link_name)
{
	var newImg = new Image();
	newImg.src = "images/"+link_name+".png";
	$("#img-lightbox").attr("height","newImg.height");
	$("#img-lightbox").attr("width","newImg.width");
} 